package com.evil.account.api;

import com.evil.account.config.FeignErrorDecoder;
import com.evil.common.account.dto.FindByNameAndEIdReqDTO;
import com.evil.common.account.dto.FindByNamesAndEIdReqDTO;
import com.evil.common.account.dto.department.*;
import com.evil.common.core.constant.ServiceNameConstant;
import com.evil.common.core.dto.FindByIdsReqDTO;
import com.evil.common.core.entity.QueryModel;
import com.github.pagehelper.PageInfo;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.List;
import java.util.Map;

/**
 * 部门接口
 *
 * @author liyang
 * @date 2022-08-08 00:00
 */
@FeignClient(name = ServiceNameConstant.ACCOUNT_SERVICE, configuration = {FeignErrorDecoder.class})
public interface RemoteDepartmentService {

    /**
     * 通过部门id查询部门基础信息
     *
     * @param departmentId departmentId
     * @return department
     */
    @PostMapping("/remote/find/department/by-base-id")
    DepartmentBaseRespDTO findBaseById(@RequestParam("id") Long departmentId);

    /**
     * 通过部门name查询部门基础信息
     *
     * @param findByNameAndEIdReqDTO findByNameAndEIdReqDTO
     * @return department
     */
    @PostMapping("/remote/find/department/by-base-name")
    DepartmentBaseRespDTO findBaseByName(@Validated @RequestBody FindByNameAndEIdReqDTO findByNameAndEIdReqDTO);

    /**
     * 通过部门ids查询部门基础信息
     *
     * @param findByIdsReqDTO findByIdsReqDTO
     * @return department
     */
    @PostMapping("/remote/find/department/by-base-ids")
    List<DepartmentBaseRespDTO> findBaseByIds(@Validated @RequestBody FindByIdsReqDTO findByIdsReqDTO);

    /**
     * 通过部门names查询部门基础信息
     *
     * @param findByNamesAndEIdReqDTO findByNamesAndEIdReqDTO
     * @return department
     */
    @PostMapping("/remote/find/department/by-base-names")
    List<DepartmentBaseRespDTO> findBaseByNames(@Validated @RequestBody FindByNamesAndEIdReqDTO findByNamesAndEIdReqDTO);

    /**
     * 通过部门names查询部门基础信息
     *
     * @param findByNamesAndEIdReqDTO findByNamesAndEIdReqDTO
     * @return department
     */
    @PostMapping("/remote/find/department/by-base-map-names")
    Map<String, DepartmentBaseRespDTO> findBaseMapByNames(@Validated @RequestBody FindByNamesAndEIdReqDTO findByNamesAndEIdReqDTO);

    /**
     * 通过部门ids查询部门基础信息
     *
     * @param findByIdsReqDTO findByIdsReqDTO
     * @return department
     */
    @PostMapping("/remote/find/department/by-base-map-ids")
    Map<Long, DepartmentBaseRespDTO> findBaseMapByIds(@Validated @RequestBody FindByIdsReqDTO findByIdsReqDTO);

    /**
     * 新增部门
     *
     * @param addDepartmentReqDTO addDepartmentReqDTO
     */
    @PostMapping("/remote/department/add")
    void add(@Validated @RequestBody AddDepartmentReqDTO addDepartmentReqDTO);

    /**
     * 编辑部门
     *
     * @param modifyDepartmentReqDTO modifyDepartmentReqDTO
     */
    @PostMapping("/remote/department/modify")
    void modify(@Validated @RequestBody ModifyDepartmentReqDTO modifyDepartmentReqDTO);

    /**
     * 获取部门分页列表
     *
     * @param queryModel queryModel
     * @return PageInfo
     */
    @PostMapping("/remote/department/list")
    PageInfo<DepartmentPageRespDTO> page(@Validated @RequestBody QueryModel<DepartmentPageReqDTO> queryModel);

    /**
     * 删除部门
     *
     * @param deleteDepartmentReqDTO deleteDepartmentReqDTO
     */
    @PostMapping("/remote/department/delete")
    void delete(@Validated @RequestBody DeleteDepartmentReqDTO deleteDepartmentReqDTO);

    /**
     * 获取部门基础信息树
     *
     * @param departmentTreeReqDTO departmentBaseTreeReqDTO
     * @return PageInfo
     */
    @PostMapping("/remote/department/department/base-tree")
    List<DepartmentBaseTreeRespDTO> baseTree(@Validated @RequestBody DepartmentTreeReqDTO departmentTreeReqDTO);

    /**
     * 获取部门树
     *
     * @param departmentTreeReqDTO departmentBaseTreeReqDTO
     * @return PageInfo
     */
    @PostMapping("/remote/department/department/tree")
    List<DepartmentTreeRespDTO> tree(@Validated @RequestBody DepartmentTreeReqDTO departmentTreeReqDTO);

    /**
     * 企业部门基础列表
     *
     * @param departmentBasesReqDTO departmentBasesReqDTO
     * @return DepartmentBaseRespDTO 列表
     */
    @PostMapping("/remote/department/bases")
    List<DepartmentBaseRespDTO> bases(@Validated @RequestBody DepartmentBasesReqDTO departmentBasesReqDTO);
}
